Skip to content

Format inline CASE <expression> WHEN correctly#86

Merged
shssoichiro merged 3 commits intoshssoichiro:masterfrom
lu-zero:unbreak-inline-case
Aug 15, 2025
Merged

Format inline CASE <expression> WHEN correctly#86
shssoichiro merged 3 commits intoshssoichiro:masterfrom
lu-zero:unbreak-inline-case

Conversation

@lu-zero
Copy link
Copy Markdown
Contributor

@lu-zero lu-zero commented Aug 13, 2025

CASE END and ( and ) have different requirements regarding the whitespace

toolchain: nightly
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I should get dependabot set up on this repo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would be good.

@shssoichiro shssoichiro requested a review from Copilot August 15, 2025 17:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the formatting of inline CASE expressions to ensure proper whitespace handling. The primary change ensures that inline CASE statements have a space added before them when inside an inline block.

  • Updates four instances in the tokenizer to use next_back() instead of last() for better performance
  • Adds whitespace handling for inline CASE expressions in the formatter
  • Includes a test case to verify the fix for CASE expressions in ORDER BY clauses
  • Updates GitHub Actions workflow dependencies

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/tokenizer.rs Replaces split(' ').last() with split(' ').next_back() for performance optimization
src/formatter.rs Adds space before inline CASE expressions to fix formatting
src/lib.rs Adds test case for CASE WHEN expressions inside ORDER BY clauses
.github/workflows/sqlformat.yml Updates GitHub Actions to use newer versions of checkout, cache, and toolchain actions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@shssoichiro shssoichiro merged commit e1e8621 into shssoichiro:master Aug 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants